Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

benedict: monkeypatch, performance improvements, bugfixes #6706

Merged
merged 1 commit into from
Oct 1, 2021

Conversation

skshetry
Copy link
Member

Fixes #6476, fixes #6423 and closes #6484.

@skshetry skshetry added enhancement Enhances DVC A: experiments Related to dvc exp skip-changelog Skips changelog bugfix fixes bug optimize Optimizes DVC labels Sep 29, 2021
@skshetry skshetry requested a review from a team as a code owner September 29, 2021 06:53
@skshetry skshetry self-assigned this Sep 29, 2021
@skshetry skshetry requested a review from pmrowla September 29, 2021 06:53
Comment on lines -90 to -97
else:
# NOTE: the following line may seem like an unnecessary duplication
# data.merge might affect the `src` if it's not empty, so we cannot
# check `if src` later, as it may have been mutated already.
data.merge(to_update, overwrite=True)
# benedict has issues keeping references to an empty dictionary
# see: https://github.com/iterative/dvc/issues/6374.
src.update(data)
Copy link
Member Author

@skshetry skshetry Sep 29, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This else was for a bug in the benedict, and it has been fixed. To resolve this bug, that monkeypatch I mentioned was introduced 😢. We no longer need this else block, and tests should cover this if it breaks again in the future.

Comment on lines +230 to +234
def test_benedict_rollback_its_monkeypatch():
from dvc.utils._benedict import benedict

assert benedict({"foo": "foo"}) == {"foo": "foo"}
assert encoder.c_make_encoder
Copy link
Member Author

@skshetry skshetry Sep 29, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test for the monkeypatch that we rollback.

@@ -203,10 +215,20 @@ def test_merge_params(changes, expected):
[{"foo": "baz"}, {"foo": "baz"}],
[{"foo": "baz", "goo": "bar"}, {"foo": "baz", "goo": "bar"}],
[{"foo[1]": ["baz", "goo"]}, {"foo": [None, ["baz", "goo"]]}],
[{"foo.bar": "baz"}, {"foo": {"bar": "baz"}}],
Copy link
Member Author

@skshetry skshetry Sep 29, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Testing for scenario mentioned in #6476, coupled with is_serializable assertion below.

@skshetry skshetry mentioned this pull request Sep 29, 2021
2 tasks
@skshetry skshetry enabled auto-merge (squash) September 29, 2021 07:28
Copy link
Contributor

@efiop efiop left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've also talked that it might be easier to throw it out maybe, wdyt about that option right now?

@skshetry
Copy link
Member Author

With this #6521 also requiring significant part of benedict and that we need to imitate it's syntax, I think it's much easier to workaround performance issue.

I do believe that we should have these small utilities in DVC itself, and try to avoid small dependencies moving forward.

@skshetry skshetry requested a review from efiop September 30, 2021 15:05
Copy link
Contributor

@pmrowla pmrowla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

It does seem like in the long run we should try to get away from having these kinds of dependencies in DVC, but in the short term benedict does work for us (with this patch), and this will unblock #6521

@skshetry skshetry merged commit 1e0b2d7 into iterative:master Oct 1, 2021
@skshetry skshetry deleted the jail-benedict branch October 1, 2021 09:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A: experiments Related to dvc exp bugfix fixes bug enhancement Enhances DVC optimize Optimizes DVC skip-changelog Skips changelog
Projects
None yet
3 participants